package com.hyz.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.hyz.pojo.Asset;
import com.hyz.pojo.AssetStatusEnum;
import com.hyz.service.AssetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author HGD
 * @date 2022/10/3 18:06
 */
@RestController
@RequestMapping("/asset")
public class AssetController {
    @Autowired
    private AssetService assetService;

    @PostMapping("/getUnassignedAssets")
    public List<Asset> getUnassignedAssets() {
        LambdaQueryWrapper<Asset> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Asset::getStatus, AssetStatusEnum.UNASSIGNED.getKey());
        return assetService.list(wrapper);
    }


    @PostMapping("/getAssetById")
    public Asset getAssetById(@RequestBody Long id) {
        return assetService.getById(id);
    }

}
